$(function(){
	var banner = new Swiper('.banner .swiper-container', {
		loop:true,
		speed:2000,
		autoplay:{
			delay: 5000,
			disableOnInteraction: false,
		},
		pagination: {
			el: '.swiper-pagination',
		},
	});
	
	
	var swiper = new Swiper('.idxOneSwiper', {
		speed: 1000,
		paginationClickable: true,
		slidesPerView: 'auto',
		spaceBetween: 0,
		noSwiping : true,
		observer: true,
		observeParents: true,
		freeMode: true,
		on:{
			click:function(){
				console.log(this.clickedIndex);
				a(this.clickedIndex);
			}
		},
		breakpoints: {
			767: {
				noSwiping : false,
				slidesPerView: 3.55,
			}
		}
	});
	
	function a(i){
		$(".ipro-page-li.active .swiper-slide")
		.eq(i)
		.addClass('active')
		.siblings()
		.removeClass('active');
		
		$(".ipro-page-li.active .idxOtab-li")
		.eq(i)
		.addClass('active')
		.siblings()
		.removeClass('active');
		
	};
	
	$('.idxOneSwiper .swiper-slide').on('click',function(e){
		$(this)
		.addClass('active')
		.siblings()
		.removeClass('active');
		
		var i=$(this).parent().children().index(this);
		
		$(".ipro-page-li.active .idxOtab-li")
		.eq(i)
		.addClass('active')
		.siblings()
		.removeClass('active');
		
	});
	
	$('.index-pro-nav li').on('click',function(e){
		var idx=$('.index-pro-nav li').index(this);
		$(this).addClass('on').siblings().removeClass('on');
		var index=$('.ipro-page-li')[idx];
		$(index).addClass('active').siblings().removeClass('active');
	});
	
	
	
	var swiper = new Swiper('.idxOtab1Swiper', {
		loop: true,
		speed: 1000,
		slidesPerView: 3,
		spaceBetween: 25,
		nextButton: '.idxOtab1_next',
		prevButton: '.idxOtab1_prev',
		observer: true,
		observeParents: true,
		breakpoints: {
			1200:{
				slidesPerView: 2,
				spaceBetween: 20,
			},
			767: {
				slidesPerView: 1,
				spaceBetween: 10,
			}
		}
	});
	
	
	
	
	var caseliswiper = new Swiper('.index-caseli-swiper .swiper-container', {
		slidesPerView: 7,
		spaceBetween: 0,
		noSwiping : true,
		freeMode: true,
		watchSlidesVisibility: true,
		watchSlidesProgress: true,
		on:{
			click:function(){
				b(this.clickedIndex);
			}
		},
		breakpoints: {
			767: {
				slidesPerView: 3.55,
				spaceBetween: 10,
			}
		}
	});
	
	var caseswiper = new Swiper('.index-case-swiper .swiper-container', {
		spaceBetween: 0,
		thumbs: {
			swiper: caseliswiper,
		}
	});
	
	
	function b(i){
		// swiper-slide-thumb-active
		$(".index-caseli-swiper .swiper-slide")
		.eq(i)
		.addClass('swiper-slide-caseli-active')
		.siblings()
		.removeClass('swiper-slide-caseli-active');
	};
	
	
	
	var swiper = new Swiper('.news-swiper .swiper-container', {
		slidesPerView: 1,
		noSwiping : true,
		navigation: {
			nextEl: '.swiper-button-next',
			prevEl: '.swiper-button-prev',
		},
		breakpoints: {
			767: {
				slidesPerView: 1,
			}
		}
	});
	
	
	var ab1 = new Swiper('.ab1 .text .swiper-container', {
		direction: 'vertical',
		slidesPerView: 'auto',
		freeMode: true,
		noSwiping:false,
		mousewheel: true,
		scrollbar: {
			el: '.swiper-scrollbar',
		},
		breakpoints: {
			991: {
				slidesPerView: 1,
				noSwiping:true,
			}
		}
	});

	var mySwiper = new Swiper('.ab3 .swiper-container',{
		pagination: {
			el: '.ab3 .swiper-pagination',
			type: 'progressbar',
			renderProgressbar: function (progressbarFillClass) {
				return '<span class="' + progressbarFillClass + '"></span>';
			}
		},
	});
	
	
	
	
	var swiper = new Swiper('.case-nav-swiper .swiper-container', {
		speed: 1000,
		paginationClickable: true,
		slidesPerView: 'auto',
		spaceBetween: 0,
		noSwiping : true,
		observer: true,
		observeParents: true,
		freeMode: true,
		breakpoints:{
			767: {
				noSwiping : false,
				slidesPerView: 3.55,
			},
			500:{
				noSwiping : false,
				slidesPerView: 2.55,
			}
		}
	});
	
	
	
	var swiper = new Swiper('.casevswiper .swiper-container', {
		slidesPerView: 1,
		spaceBetween: 20,
		centeredSlides : true,
		navigation: {
			nextEl: '.swiper-button-next',
			prevEl: '.swiper-button-prev',
		},
	});
	
	
	var swiper = new Swiper('.recommend .swiper-container', {
		slidesPerView: 5,
		noSwiping : true,
		spaceBetween: 50,
		pagination: {
			el: '.swiper-pagination',
		},
		breakpoints:{
			1600: {
				noSwiping : false,
				slidesPerView: 4,
			},
			1200:{
				noSwiping : false,
				slidesPerView: 3,
			},
			767:{
				noSwiping : false,
				slidesPerView: 2,
			},
			500:{
				noSwiping : false,
				slidesPerView: 1,
			}
		}
		
	});
	
	
	
	var swiper = new Swiper('.prov .container > .swiper-container', {
		slidesPerView: 'auto',
		pagination: {
			el: '.swiper-pagination',
		},
		breakpoints: {
			767: {
				
			}
		}
	});
	
	var swiper = new Swiper('.prov .text_box .swiper-container', {
		direction: 'vertical',
		slidesPerView: 'auto',
		freeMode: true,
		noSwiping:false,
		mousewheel: true,
		scrollbar: {
			el: '.swiper-scrollbar',
		},
		breakpoints: {
			1200: {
				slidesPerView: 1,
				noSwiping:true,
			}
		}
	});
	
	
	
	
	var swiper = new Swiper('.jion-brand .swiper-container', {
		slidesPerView: 3,
		spaceBetween: 30,
		noSwiping : true,
		pagination: {
			el: '.swiper-pagination',
		},
		breakpoints:{
			767:{
				slidesPerView: 2,
				noSwiping : false,
			},
			500:{
				slidesPerView: 1,
				noSwiping : false,
			}
		}
		
	});
	
	
	
	var swiper = new Swiper('.about-swiper', {
		spaceBetween: 30,
		navigation: {
			nextEl: '.swiper-button-next',
			prevEl: '.swiper-button-prev',
		},
	});
	
	var swiper = new Swiper('.sales-swiper', {
		spaceBetween: 30,
		slidesPerView:4,
		pagination: {
		    el: '.swiper-pagination',
		  },
		breakpoints:{
			1280:{
				noSwiping:false,
				slidesPerView: 3,
			},
			991:{
				noSwiping:false,
				slidesPerView: 2,
			},
			640:{
				noSwiping:false,
				slidesPerView: 1,
			}
		}
	});
	
	
	$('.search-box').on('click',function(){
		$('.head_form').slideToggle();
	});
	
	$('.case-nav-swiper li').on('click',function(e){
		var idx=$('.caseSwiper li').index(this);
		$(this).addClass('active').siblings().removeClass('active');
		// var index=$('.ipro-page-li')[idx];
		// $(index).addClass('active').siblings().removeClass('active');
	});
	
	
	
	$('.publicnav h3').on('click',function(){
		$(this).next().find('ul.bd').slideUp();
		$(this).next().slideToggle();
	});
	
	$('.navToggle').on('click',function(){
		$(this).toggleClass('active');
		$('.mblNav').slideToggle();
	});
	
	
	$('.footer3 h4').on('click',function(){
		$('.friend-link').toggle();
	});
	
	$('.booking-content dt').on('click',function(){
		$(this).next().slideToggle();
	});
	
	
	$('.booking-content dl').on('mouseleave',function(){
		$('.booking-content dd').slideUp();
	});
	
	$('.index-pro-nav h3').on('click',function(){
		$(this).next().slideToggle();
	});
	
	$('.pro-nav>ul>li>a').on('click',function(){
		$(this).next().slideToggle().parent().siblings().find('ul').slideUp();
	});
	
	
	// $('.index-news-list .index-news-box').on('mouseenter',function(){
	// 	var idx=$('.index-news-list .index-news-box').index(this);
	// 	$(this).addClass('active').siblings().removeClass('active');
	// });
	
	
	$('a.search').on('click',function(){
		$(this).next().fadeToggle();
	});
	
	
	$('.showroom .list-box .list:nth-of-type(1)').on('click',function(){
		$('.zhezhao').addClass('on');
		$('.login').addClass('on');
	});
	
	
	
	$('.zhezhao').on('click',function(){
		$('.zhezhao').removeClass('on');
		$('.login').removeClass('on');
	});
	
	
	$('.lang').on('click',function(){
		$(this).children().slideToggle();
	});
	
	$('.lang').on('mouseleave',function(){
		$(this).children().slideUp();
	});
	
	
	if(window.innerWidth < 991){
		$('.fnav-box h3').on('click',function(){
			$(this).next().slideToggle().parent().siblings().children('ul').slideUp();
		});
	};
	
	if(window.innerWidth < 768){
		$('.ipro-navli').on('click',function(){
			$(this).parent().slideUp();
		})
	};
	
	$('.stick').click(function(){
		// 1.秒置顶
		// var y = window.scrollY;
		// scrollTo(0,0);
		// console.log(y);
		
		// 2.缓慢置顶
		var i=200;
		var myVar=setInterval(function(){
			scrollTo(0,window.scrollY-i);
			if(window.scrollY-i<0){
				clearInterval(myVar)
				scrollTo(0,0);
			}
		},20)
	});
	
	
	$(window).scroll(function(){
		console.log($(window).scrollTop());
		console.log($(".nav-box").offset().top);
		console.log($(window).scrollTop() - $(".nav-box").offset().top);
		if($(window).scrollTop()-$(".nav-box").offset().top>-1){
			$(".nav-box").addClass('on');
		}else{
			$(".nav-box").removeClass('on');
		}
	});
	
});